package com.ruoyi.web.controller.uav;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.uav.domain.UavTaskSteps;
import com.ruoyi.uav.service.IUavTaskStepsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 任务流程记录Controller
 *
 * @author ruoyi
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/uav/steps")
@Api(value = "任务流程记录控制层", tags = "任务流程记录控制层")
public class UavTaskStepsController extends BaseController {
    @Resource
    private IUavTaskStepsService uavTaskStepsService;

    /**
     * 查询任务流程记录列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询任务流程记录列表", notes = "传入uavTaskSteps")
    public TableDataInfo list(UavTaskSteps uavTaskSteps) {
        startPage();
        List<UavTaskSteps> list = uavTaskStepsService.selectUavTaskStepsList(uavTaskSteps);
        return getDataTable(list);
    }

    /**
     * 导出任务流程记录列表
     */
    @Log(title = "任务流程记录", businessType = BusinessType.EXPORT)
    @RepeatSubmit(interval = 2000, message = "请求过于频繁")
    @GetMapping("/export")
    @ApiOperation(value = "导出任务流程记录列表", notes = "传入uavTaskSteps")
    public AjaxResult export(UavTaskSteps uavTaskSteps) {
        List<UavTaskSteps> list = uavTaskStepsService.selectUavTaskStepsList(uavTaskSteps);
        ExcelUtil<UavTaskSteps> util = new ExcelUtil<UavTaskSteps>(UavTaskSteps.class);
        return util.exportExcel(list, "任务流程记录数据");
    }

    /**
     * 获取任务流程记录详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取任务流程记录详细信息", notes = "传入id")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(uavTaskStepsService.getInfo(id));
    }

    /**
     * 新增任务流程记录
     */
    @Log(title = "任务流程记录", businessType = BusinessType.INSERT)
    @RepeatSubmit(interval = 2000, message = "请求过于频繁")
    @PostMapping
    @ApiOperation(value = "新增任务流程记录", notes = "传入uavTaskSteps")
    public AjaxResult add(@RequestBody UavTaskSteps uavTaskSteps) {
        return success(uavTaskStepsService.save(uavTaskSteps));
    }

    /**
     * 修改任务流程记录
     */
//    @Log(title = "任务流程记录", businessType = BusinessType.UPDATE)
//    @RepeatSubmit(interval = 2000, message = "请求过于频繁")
//    @PutMapping
//    @ApiOperation(value = "修改任务流程记录", notes = "传入uavTaskSteps")
//    public AjaxResult edit(@RequestBody UavTaskSteps uavTaskSteps) {
//        return success(uavTaskStepsService.updateById(uavTaskSteps));
//    }

    /**
     * 删除任务流程记录
     */
//    @Log(title = "任务流程记录", businessType = BusinessType.DELETE)
//    @RepeatSubmit(interval = 2000, message = "请求过于频繁")
//	@DeleteMapping("/{ids}")
//    @ApiOperation(value = "删除任务流程记录", notes = "传入ids")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return success(uavTaskStepsService.removeBatchByIds(Arrays.asList(ids)));
//    }
}
